import warnings
warnings.filterwarnings('ignore')
from ultralytics import YOLO
# import wandb
# from wandb.integration.ultralytics import add_wandb_callback

# wandb.login()
# wandb.init(
#     project="rm-2025",
#     config={
#         "epochs": 500,
#         "batch_size": 64,  
#         "workers": 8,
#     }
# )
# config = wandb.config

if __name__ == '__main__':
    model = YOLO(model="/home/hxt/ultralytics-main/runs/exp3/weights/last.pt",task="segment")
    # model = YOLO(model="/home/hxt/ultralytics-main/ultralytics/cfg/models/11/yolo11m-seg.yaml",task="segment").load("yolo11m-seg.pt") 
    # add_wandb_callback(model)
    model.train(data= r"/home/hxt/ultralytics-main/rm_train_val/RM_data_seg.yaml",
                cache=True,
                imgsz=[1024,1024],
                epochs=500,
                single_cls=False,  # 是否是单类别检测
                batch= 8,              
                close_mosaic=0,
                workers=4,
                device='1,2',
                optimizer='Adam', # using Adam 优化器 默认为auto建议大家使用固定的.
                resume=True, # 续训的话这里填写True, yaml文件的地方改为lats.pt的地址,需要注意的是如果你设置训练200轮次模型训练了200轮次是没有办法进行续训的.
                amp=False,  # 如果出现训练损失为Nan可以关闭amp
                project='runs',
                name='exp',
                )
    # wandb.finish()
